<template>
	<view class="mainbgc">
		<header-top :messageInfo="{typeFlag:true,message:'订阅',liner:false}">
			<view class="rightmsg" slot="rightmsg">
				<view class="rightmsg_content flexleft">
					<view class="nostrongtext" style="color: #0BBDCB;" @click="subscribe_edit">确定</view>
				</view>
			</view>
		</header-top>
		<view class="mainpadding2">
			<view class="margin_top" v-for="item in list" :key="item.id">
				<view class="newsflex">
					<view class="flexleft">
						<view class="lefticon">
							<image :src="item.image" mode=""></image>
						</view>
						<view class="titletext textliner">{{item.title}}</view>
					</view>
					<view class="margin_top">
						<u-switch v-model="item.is_show" activeColor="#64d777"></u-switch>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				list: [
					{
						id:1,
						image:require("@/static/image/news/news1.png"),
						title:"政策发文",
						is_show:true,
					},
					{
						id:2,
						image:require("@/static/image/news/news2.png"),
						title:"公司制度",
						is_show:true,
					},
					{
						id:3,
						image:require("@/static/image/news/news3.png"),
						title:"最新通知",
						is_show:true,
					},
					{
						id:4,
						image:require("@/static/image/news/news4.png"),
						title:"平台信息",
						is_show:true,
					},
					{
						id:5,
						image:require("@/static/image/news/news5.png"),
						title:"客户流失预警",
						is_show:true,
					},
					{
						id:6,
						image:require("@/static/image/news/news6.png"),
						title:"仓库预警",
						is_show:true,
					},
					{
						id:7,
						image:require("@/static/image/news/news7.png"),
						title:"盘点单",
						is_show:true,
					},
					{
						id:8,
						image:require("@/static/image/news/news8.png"),
						title:"采购单审核",
						is_show:true,
					},
					{
						id:9,
						image:require("@/static/image/news/news9.png"),
						title:"采购退货单审核",
						is_show:true,
					},
					{
						id:10,
						image:require("@/static/image/news/news10.png"),
						title:"销售单审核",
						is_show:true,
					},
					{
						id:11,
						image:require("@/static/image/news/news11.png"),
						title:"销售退货单审核",
						is_show:true,
					},
					
					{
						id:12,
						image:require("@/static/image/news/news12.png"),
						title:"出库单审核",
						is_show:true,
					},
					{
						id:13,
						image:require("@/static/image/news/news13.png"),
						title:"入库单审核",
						is_show:true,
					},
					{
						id:14,
						image:require("@/static/image/news/news14.png"),
						title:"调拨单审核",
						is_show:true,
					},
					{
						id:15,
						image:require("@/static/image/news/news15.png"),
						title:"请假审核",
						is_show:true,
					},
					{
						id:16,
						image:require("@/static/image/news/news15.png"),
						title:"费用支出审核",
						is_show:true,
					},]
			}
		},
		onLoad() {
			if(uni.getStorageSync("newsflag")){
				let arr = JSON.parse(uni.getStorageSync("newslist"))
				this.list.forEach(item=>{
					item.is_show = false
					arr.forEach(ite=>{
						if(item.id==ite){
							item.is_show = true
						}
					})
				})
			}
		},
		methods: {
			// 修改订阅内容
			subscribe_edit(){
				let ids = []
				this.list.forEach(item=>{
					if(item.is_show){
						ids.push(item.id)
					}
				})
				uni.setStorageSync("newslist",JSON.stringify(ids))
				uni.setStorageSync("newsflag",true)
				uni.navigateBack(1)
			},
			changezk(ite){
				ite.is_zk = ite.is_zk?false:true
			}
		}
	}
</script>

<style lang="scss" scoped>
	.newsflex {
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
		padding: 30rpx 0;
		border-bottom: 1rpx solid rgba(0, 0, 0, 0.02);
	}

	.lefticon {
		width: 84rpx;
		height: 84rpx;
		margin-right: 20rpx;
		image {
			width: 100%;
			height: 100%;
		}
	}

	// 收起的内容
	.newstext {
		width: 360rpx;
		overflow: hidden;
		/*隐藏*/
		white-space: nowrap;
		/*不换行*/
		text-overflow: ellipsis;
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		color: #666666;
		line-height: 32rpx;
	}

	// 更多的内容
	.newstextshow {
		width: 360rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		color: #666666;
		line-height: 32rpx;
	}

	.moretext {
		margin-left: 30rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		color: #0BBDCB;
		line-height: 32rpx;
	}
	.xiankuan{
		width: 300rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
</style>
